package stack;

public class RemoveStars {
    public String removeStars(String s) {
        StringBuilder result = new StringBuilder();

        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '*') {
                // 找到星号，移除星号左侧最近的非星号字符
                result.deleteCharAt(result.length() - 1);
            } else {
                // 将非星号字符添加到结果字符串中
                result.append(s.charAt(i));
            }
        }

        return result.toString();
    }
}
